{%include file="index.header.tpl.php"%}
{%include file="index.left.tpl.php"%}
<!--主要内容开始-->
  <div class="content-wrapper">
    <section class="content">
      <div class="row">
        <section class="col-lg-12 connectedSortable">
         <div class="box box-default box-solid">
          <form action="" method="post" name="formname">
                <div class="box-header with-border">
                    <span class="fa fa-level-up" style="float:left; font-size:18px; margin-top:2px; color:#3c8dbc;" ></span>
                    <p class="box-title">班级升迁</p>
                </div>
                     <div class="box-body">
                        <!--选择部分-->
                        <div class="selectbox col-md-12">
							<div class="select-bar col-sm-5">
							   <div class="form-group" style="background-color:#d9edf7; margin-bottom:0; padding-bottom:8px; padding-top:8px;">
                                    <label class="col-md-3 control-label text-right" for="inputPassword3" style="font-weight:500;">
                                         原年级：
                                    </label>
                                    <div class="input-group col-md-8">
                                        <select style="width:220px; height:30px;" id="class_id1" name="grade_id">
                                            <option value="">请选择年级</option>
											 {%foreach from=$grade_lists key=key item=value%}
                                             <option value="{%$value.grade_id%}">{%$value.grade_name%}</option>
                                             {%/foreach%}
                                         </select>
                                    </div>
                                </div> 
								<select class="form-control third select" multiple="multiple" id="select1">
									<option value="">请选择</option>
								</select>
							</div>
							<div class="btn-bar col-sm-1" style="padding-top:90px; padding-left:3px;">
								<p><span id="add"><input type="button" class="btn btn-default btn-sm" value="添加>>" title="移动选择项到右侧"/></span></p>
								<p><span id="remove"><input type="button" class="btn btn-default btn-sm" value="<<添加" title="移动选择项到左侧"/></span></p>
							</div>
							<div class="select-bar col-sm-5">
							     <div class="form-group" style="background-color:#d9edf7; margin-bottom:0; padding-bottom:8px; padding-top:8px;">
                                    <label class="col-md-3 control-label text-right" for="inputPassword3" style="font-weight:500;">
                                         目的年级：
                                    </label>
                                    <div class="input-group col-md-8">
                                        <select style="width:220px; height:30px;" id="class_id2" name="grade_id">
                                             <option value="">请选择年级</option>
											 {%foreach from=$grade_lists key=key item=value%}
                                             <option value="{%$value.grade_id%}">{%$value.grade_name%}</option>
                                             {%/foreach%}
                                         </select>
                                    </div>
                                </div> 
								 <select class="form-control" multiple="multiple" id="select2">
                                    <option value="">请选择</option>
							
                                 </select>
							</div>	
						</div>	
                            <!--<div class="col-sm-2 form-group" style="padding-top:18px; margin-left:15px;">
                                   <button class="btn btn-default" onclick='SelectAll()'>全选</button>                           
                             </div>--> 
                            <div class="col-sm-3 form-group" style="padding-top:20px; margin-left:15px;">
                                  <label><input type="checkbox" name="teacher[]"> 班主任随班升迁</label>
                            </div>  
				   </div><!--box-body -->
                    
                   <div class="box-footer text-center">      
                        <button type="submit" class="btn btn-primary" onClick="test();">保 存</button>
                   </div>
                 </form> 
             </div><!--box box-default box-solid-->
        </section>   
           
        </div><!--row-->
    </section>
 </div>
  <!--主要内容结束-->
{%include file="index.footer.tpl.php"%}
<script src="static/js/jquery.cxselect.min.js"></script>
<script type="text/javascript">
$(function(){	
	//移到右边
	$('#add').click(function(){
		//先判断是否有选中
		if(!$("#select1 option").is(":selected")){			
			alert("请选择需要移动的选项")
		}
		//获取选中的选项，删除并追加给对方
		else{
			$('#select1 option:selected').appendTo('#select2');
		}	
	});
	
	$('#remove').click(function(){
		//先判断是否有选中
		if(!$("#select2 option").is(":selected")){			
			alert("请选择需要移动的选项")
		}
		else{
			$('#select2 option:selected').appendTo('#select1');
		}
	});
	
	//全部移到右边
	$('#add_all').click(function(){
		//获取全部的选项,删除并追加给对方
		$('#select1 option').appendTo('#select2');
	});
	
	//全部移到左边
	$('#remove_all').click(function(){
		$('#select2 option').appendTo('#select1');
	});
	
	//双击选项
	$('#select1').dblclick(function(){ //绑定双击事件
		//获取全部的选项,删除并追加给对方
		$("option:selected",this).appendTo('#select2'); //追加给对方
	});
	
	//双击选项
	$('#select2').dblclick(function(){
		$("option:selected",this).appendTo('#select1');
	});
	
});
</script>
<script type="text/javascript">
	
		  function test(){
			
			var str = $("#select1 option").map(function(){return $(this).val();}).get().join(",");
			$('#s1').val(str);
	
			var str = $("#select2 option").map(function(){return $(this).val();}).get().join(",");
			$('#s2').val(str);

		  }
		 
</script>




<script type="text/javascript">
        $(document).ready(function () {
            $("#class_id1").change(function () {		
                if ($(this).val() == "-1") {
					$("#industr").remove(); return; 
					}
                else {
			var timestamp = new Date().getTime();
			$.ajax({
			url:"index.php?a=student.gradejson",
			type:"get",
			data: "grade_id=" + $("#class_id1").find("option:selected").val() + "&timestamp=" + timestamp,
			dataType:"json",
			success:function(msg){
			   
                            //实例2个字符串变量来拼接下拉列表
                            var industr = "";
                            //使用jquery解析json中的数据
                            $.each(msg, function (n, value) {
                                industr += ("<option value=\"" + value.student_id + "\">" + value.student_school+"-"+ value.student_sex+"-"+ value.student_name);
                                industr += ("</option>");
                            });

                            $("#select1").html(industr);			   			   
			}
			});					

                }

            });

        });
</script>
<script type="text/javascript">
        $(document).ready(function () {
            $("#class_id2").change(function () {		
                if ($(this).val() == "-1") {
					$("#industr").remove(); return; 
					}
                else {
			var timestamp = new Date().getTime();
			$.ajax({
			url:"index.php?a=student.gradejson",
			type:"get",
			data: "grade_id=" + $("#class_id2").find("option:selected").val() + "&timestamp=" + timestamp,
			dataType:"json",
			success:function(msg){
			   
                            //实例2个字符串变量来拼接下拉列表
                            var industr = "";
                            //使用jquery解析json中的数据
                            $.each(msg, function (n, value) {
                                industr += ("<option value=\"" + value.student_id + "\">" + value.student_school+"-"+ value.student_sex+"-"+ value.student_name);
                                industr += ("</option>");
                            });

                            $("#select2").html(industr);			   			   
			}
			});					

                }

            });

        });
</script>
